package ace.module.oauth2.server.core.impl.dao.entity;

import jakarta.annotation.Nullable;
import io.swagger.v3.oas.annotations.media.Schema;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.experimental.SuperBuilder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.annotation.Version;
import org.springframework.data.relational.core.mapping.Table;
import jakarta.validation.constraints.Size;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.NotEmpty;
import java.io.Serializable;
import ace.cmp.spring.data.jdbc.querydsl.core.annotations.LogicDelete;
import ace.cmp.spring.graphql.core.model.GenericPageContent;
import ace.module.oauth2.server.api.model.dto.Oauth2AuthorizationDto;

/**
* 客户端认证的令牌.
*
* @author Caspar
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(title = Oauth2AuthorizationDto.TABLE_DESC)
@Table(Oauth2AuthorizationDto.TABLE_NAME)
public class Oauth2Authorization implements Serializable, GenericPageContent<String> {

  @Id
  @Size(max = 255)
  @Schema(title = Oauth2AuthorizationDto.ID_TITLE, description = Oauth2AuthorizationDto.ID_DESC)
  private String id;

  @Size(max = 255)
  @Schema(title = Oauth2AuthorizationDto.REGISTERED_CLIENT_ID_TITLE, description = Oauth2AuthorizationDto.REGISTERED_CLIENT_ID_DESC)
  private String registeredClientId;

  @Size(max = 255)
  @Schema(title = Oauth2AuthorizationDto.PRINCIPAL_NAME_TITLE, description = Oauth2AuthorizationDto.PRINCIPAL_NAME_DESC)
  private String principalName;

  @Size(max = 255)
  @Schema(title = Oauth2AuthorizationDto.AUTHORIZATION_GRANT_TYPE_TITLE, description = Oauth2AuthorizationDto.AUTHORIZATION_GRANT_TYPE_DESC)
  private String authorizationGrantType;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.AUTHORIZATION_SCOPES_TITLE, description = Oauth2AuthorizationDto.AUTHORIZATION_SCOPES_DESC)
  private String authorizationScopes;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.ATTRIBUTES_TITLE, description = Oauth2AuthorizationDto.ATTRIBUTES_DESC)
  private String attributes;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.STATE_TITLE, description = Oauth2AuthorizationDto.STATE_DESC)
  private String state;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.AUTHORIZATION_CODE_VALUE_TITLE, description = Oauth2AuthorizationDto.AUTHORIZATION_CODE_VALUE_DESC)
  private String authorizationCodeValue;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.AUTHORIZATION_CODE_ISSUED_AT_TITLE, description = Oauth2AuthorizationDto.AUTHORIZATION_CODE_ISSUED_AT_DESC)
  private Long authorizationCodeIssuedAt;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.AUTHORIZATION_CODE_EXPIRES_AT_TITLE, description = Oauth2AuthorizationDto.AUTHORIZATION_CODE_EXPIRES_AT_DESC)
  private Long authorizationCodeExpiresAt;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.AUTHORIZATION_CODE_METADATA_TITLE, description = Oauth2AuthorizationDto.AUTHORIZATION_CODE_METADATA_DESC)
  private String authorizationCodeMetadata;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.ACCESS_TOKEN_VALUE_TITLE, description = Oauth2AuthorizationDto.ACCESS_TOKEN_VALUE_DESC)
  private String accessTokenValue;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.ACCESS_TOKEN_ISSUED_AT_TITLE, description = Oauth2AuthorizationDto.ACCESS_TOKEN_ISSUED_AT_DESC)
  private Long accessTokenIssuedAt;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.ACCESS_TOKEN_EXPIRES_AT_TITLE, description = Oauth2AuthorizationDto.ACCESS_TOKEN_EXPIRES_AT_DESC)
  private Long accessTokenExpiresAt;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.ACCESS_TOKEN_METADATA_TITLE, description = Oauth2AuthorizationDto.ACCESS_TOKEN_METADATA_DESC)
  private String accessTokenMetadata;

  @Nullable
  @Size(max = 255)
  @Schema(title = Oauth2AuthorizationDto.ACCESS_TOKEN_TYPE_TITLE, description = Oauth2AuthorizationDto.ACCESS_TOKEN_TYPE_DESC)
  private String accessTokenType;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.ACCESS_TOKEN_SCOPES_TITLE, description = Oauth2AuthorizationDto.ACCESS_TOKEN_SCOPES_DESC)
  private String accessTokenScopes;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.OIDC_ID_TOKEN_VALUE_TITLE, description = Oauth2AuthorizationDto.OIDC_ID_TOKEN_VALUE_DESC)
  private String oidcIdTokenValue;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.OIDC_ID_TOKEN_ISSUED_AT_TITLE, description = Oauth2AuthorizationDto.OIDC_ID_TOKEN_ISSUED_AT_DESC)
  private Long oidcIdTokenIssuedAt;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.OIDC_ID_TOKEN_EXPIRES_AT_TITLE, description = Oauth2AuthorizationDto.OIDC_ID_TOKEN_EXPIRES_AT_DESC)
  private Long oidcIdTokenExpiresAt;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.OIDC_ID_TOKEN_METADATA_TITLE, description = Oauth2AuthorizationDto.OIDC_ID_TOKEN_METADATA_DESC)
  private String oidcIdTokenMetadata;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.REFRESH_TOKEN_VALUE_TITLE, description = Oauth2AuthorizationDto.REFRESH_TOKEN_VALUE_DESC)
  private String refreshTokenValue;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.REFRESH_TOKEN_ISSUED_AT_TITLE, description = Oauth2AuthorizationDto.REFRESH_TOKEN_ISSUED_AT_DESC)
  private Long refreshTokenIssuedAt;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.REFRESH_TOKEN_EXPIRES_AT_TITLE, description = Oauth2AuthorizationDto.REFRESH_TOKEN_EXPIRES_AT_DESC)
  private Long refreshTokenExpiresAt;

  @Nullable
  @Schema(title = Oauth2AuthorizationDto.REFRESH_TOKEN_METADATA_TITLE, description = Oauth2AuthorizationDto.REFRESH_TOKEN_METADATA_DESC)
  private String refreshTokenMetadata;

  @LogicDelete
  @Size(max = 255)
  @Schema(title = Oauth2AuthorizationDto.DELETE_FLAG_TITLE, description = Oauth2AuthorizationDto.DELETE_FLAG_DESC)
  private String deleteFlag;

  @CreatedDate
  @Schema(title = Oauth2AuthorizationDto.CREATE_TIME_TITLE, description = Oauth2AuthorizationDto.CREATE_TIME_DESC)
  private Long createTime;

  @LastModifiedDate
  @Schema(title = Oauth2AuthorizationDto.UPDATE_TIME_TITLE, description = Oauth2AuthorizationDto.UPDATE_TIME_DESC)
  private Long updateTime;

  @Version
  @Schema(title = Oauth2AuthorizationDto.ROW_VERSION_TITLE, description = Oauth2AuthorizationDto.ROW_VERSION_DESC)
  private Long rowVersion;

}
